package com.ruoyi.web.controller.warehouse;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WarehouseCome;
import com.ruoyi.system.service.IWarehouseComeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 入库表Controller
 * 
 * @author ruoyi
 * @date 2023-05-26
 */
@RestController
@RequestMapping("/system/come")
public class WarehouseComeController extends BaseController
{
    @Autowired
    private IWarehouseComeService warehouseComeService;

    /**
     * 查询入库表列表
     */
    @PreAuthorize("@ss.hasPermi('system:come:list')")
    @GetMapping("/list")
    public TableDataInfo list(WarehouseCome warehouseCome)
    {
        startPage();
        List<WarehouseCome> list = warehouseComeService.selectWarehouseComeList(warehouseCome);
        return getDataTable(list);
    }

    /**
     * 导出入库表列表
     */
    @PreAuthorize("@ss.hasPermi('system:come:export')")
    @Log(title = "入库表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WarehouseCome warehouseCome)
    {
        List<WarehouseCome> list = warehouseComeService.selectWarehouseComeList(warehouseCome);
        ExcelUtil<WarehouseCome> util = new ExcelUtil<WarehouseCome>(WarehouseCome.class);
        util.exportExcel(response, list, "入库表数据");
    }

    /**
     * 获取入库表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:come:query')")
    @GetMapping(value = "/{warehouseComeId}")
    public AjaxResult getInfo(@PathVariable("warehouseComeId") String warehouseComeId)
    {
        return success(warehouseComeService.selectWarehouseComeByWarehouseComeId(warehouseComeId));
    }

    /**
     * 新增入库表
     */
    @PreAuthorize("@ss.hasPermi('system:come:add')")
    @Log(title = "入库表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WarehouseCome warehouseCome)
    {
        return toAjax(warehouseComeService.insertWarehouseCome(warehouseCome));
    }

    /**
     * 修改入库表
     */
    @PreAuthorize("@ss.hasPermi('system:come:edit')")
    @Log(title = "入库表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WarehouseCome warehouseCome)
    {
        return toAjax(warehouseComeService.updateWarehouseCome(warehouseCome));
    }

    /**
     * 删除入库表
     */
    @PreAuthorize("@ss.hasPermi('system:come:remove')")
    @Log(title = "入库表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{warehouseComeIds}")
    public AjaxResult remove(@PathVariable String[] warehouseComeIds)
    {
        return toAjax(warehouseComeService.deleteWarehouseComeByWarehouseComeIds(warehouseComeIds));
    }
}
